package cn.smile.feign;

import cn.smile.feign.config.FeignClientConfig;
import cn.smile.feign.hystrix.FeignHystrix;
import cn.smile.feign.hystrix.impl.FeignHystrixImpl;
import cn.smile.pojo.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.FeignClientProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 使用Feign调用服务
 *
 * @Author: MaoSuyu
 * @User：John
 * @Date: 2019/5/26
 * @Time: 16:39
 * @Description: No Description
 */
//得到服务 fallback = FeignHystrixImpl.class 里面重写了feign的方法，当feign不可用时执行重写的方法
//fallbackFactory = FeignHystrix.class 使用fallback工厂的方式实现熔断方法
@FeignClient(name = "producer-service",configuration = FeignClientConfig.class,fallbackFactory = FeignHystrix.class)
public interface Feign {

    @PostMapping("/hello")
    User getUser();


    @PostMapping("/getUser")
    User getUser(@RequestBody User user);

    @PostMapping("/test")
    String test();

    @PostMapping("/hystrix")
    String hystrix();

    @PostMapping("/server")
    String getServer();
}
